<?php
/**
 * ブログ記事一つを表すモデル
 *
 * @group model
 */
class Kishu extends DataModel
{
    protected $_schema = array(
        'id'        => parent::BIGINT
      , 'jpn'       => parent::TEXT
      , 'eng'       => parent::TEXT
      , 'note'      => parent::TEXT
      , 'upd'       => parent::DATETIME
      , 'reg'       => parent::DATETIME
      //, 'published' => parent::DATETIME
    );

    function isValid()
    {
        $error = null;
        
        $val = $this->id;
        if ((empty($val) && $val != 0) || !preg_match("/^[0-9]+$/", $val)) {
            $error['id'] = true;
        }
        
        $val = $this->jpn;
        if (empty($val) || !mb_check_encoding($val) || mb_strlen($val) > 10) {
            $error['jpn'] = true;
        }

        return $error;
    }
    
}
